<template>
  <div>
    <!-- 编辑 -->
    <el-dialog title="编辑相册" :visible="true">
      <div class="createpic">
    <div class="main">
      <el-form label-width="80px" :model="List">
        <el-form-item label="相册编号:">
          <el-input v-model="List.id"></el-input>
        </el-form-item>
        <el-form-item label="相册名称:">
          <el-input v-model="List.name"></el-input>
        </el-form-item>
        <el-form-item label="相册描述:">
          <el-input type="textarea" v-model="List.description"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
       
        <el-button @click="cancle()">取 消</el-button>
        <el-button type="primary" @click="editAlbum()">确 定</el-button>
      </span> 
    </div>
  </div>
    </el-dialog>
  </div>
</template>
<script>
import {EditAlbum} from '@/api/assetsdata'
export default {
  data() {
    return {
      visible: false,
      List:{ id: "",
        name: "",}
    };
  },
  props:{
    id: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  methods:{
 
    cancle(){
      this.$emit('close',false)
    },
    editAlbum(){
      EditAlbum(this.List).then((res) => {
        if (res.data.code === 0) {
          this.$message({
            type: "success",
            message: "编辑成功，2秒后自动返回",
          });
          setTimeout(() => {
            this.$router.back();
          }, 1500);
        }
        this.$emit('close',false)  
       
      });
    
    }
  },
  watch: {
    id: {
      handler() {
        // 当复制的visible发生变化时候更新当前组件的
        this.List = {...this.id};
      },
    },
  },
};
</script>

